﻿//using DevComponents.AdvTree;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Construction.Core
{
    public class nStories : cObj
    {
        private string name;
        private List<cObj> contents;
        public nStories()
        {
            this.contents = new List<cObj>();
            this.node.Name = base.BaseID;
        }

        public string Name
        {
            set
            {
                if (this.name != value)
                {
                    this.name = value;
                    base.Name = value;
                }
            }
            get
            {
                if (this.name == null)
                {
                    this.name = "[Tầng 1]";
                }
                return this.name;
            }
        }

        public List<nBeams> ListBeams
        {
            get
            {
                return (from e in this.contents
                        where e is nBeams
                        select e as nBeams).ToList<nBeams>();
            }
        }

        public List<nColumns> ListColumns
        {
            get
            {
                return (from e in this.contents
                        where e is nColumns
                        select e as nColumns).ToList<nColumns>();
            }
        }

        public List<nFloors> ListFloor
        {
            get
            {
                return (from e in this.contents
                        where e is nFloors
                        select e as nFloors).ToList<nFloors>();
            }
        }

        public int BeamCount
        {
            get
            {
                return this.ListBeams.Count;
            }
        }

        public int ColumnCount
        {
            get
            {
                return this.ListColumns.Count;
            }
        }

        public int FloorCount
        {
            get
            {
                return this.ListFloor.Count;
            }
        }

        public override void Add(cObj obj)
        {
            if (obj is nBeams)
            {
                nBeams beam = obj as nBeams;
                beam.OwnerID = base.BaseID;
                this.node.Name = beam.BaseID;
                this.contents.Add(beam);
            }
            else if (obj is nColumns)
            {
                nColumns column = obj as nColumns;
                column.OwnerID = base.BaseID;
                this.node.Name = column.BaseID;
                this.contents.Add(column);
            }
            else if (obj is nFloors)
            {
                nFloors floor = obj as nFloors;
                floor.OwnerID = base.BaseID;
                this.node.Name = floor.BaseID;
                this.contents.Add(floor);
            }
        }        

        //public Node node { set; get; }

        
        public int Count
        {
            get { return this.contents.Count; }
        }

    }
}
